package jxtend.annotation.keyword;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jxtend.runtime.annotation.AllowSingleMemberNotation;
import jxtend.runtime.annotation.MutuallyExclusiveGroup;

/**
 * Triggers the generation of JavaBean read (= get/is) and / or write (= set) methods for a field declaration.<br>
 * <p>
 * At default both read- and write methods will be generated.<br>
 * The exception to this rule is field with a {@code final} modifier; in this case only a read method will be generated.
 * </p><p>
 * How and which methods are generated by:<ul>
 * <li>providing a {@code name} attributes: causes another name to be used for generating the methods;</li>
 * <li>providing {@code true} for one of the {@link #readOnly()} or {@link #writeOnly()} attributes: will change which
 * methods will be generated.</li>
 * <li>providing {@code true} for one of the {@link #customMethods()}, {@link #customRead()} or {@link #customWrite()}
 * attributes: will reuse explicitly coded method(s) instead of generated method(s).</li>
 * </ul></p>
 */
@Retention(RetentionPolicy.SOURCE)
@Target({ ElementType.FIELD, ElementType.PARAMETER })
@AllowSingleMemberNotation
public @interface property {
	String name() default "";

	/** Marks the property as "read-only" */
	@MutuallyExclusiveGroup("readOrWriteOnly")
	boolean readOnly() default false;
	/** Marks the property as "write-only" */
	@MutuallyExclusiveGroup("readOrWriteOnly")
	boolean writeOnly() default false;

	@MutuallyExclusiveGroup("customMethods")
	boolean customMethods() default false;
	@MutuallyExclusiveGroup("customMethods")
	boolean customRead() default false;
	@MutuallyExclusiveGroup("customMethods")
	boolean customWrite() default false;
}
